'use strict';

const Controller = require('egg/index').Controller;

class PackageController extends Controller {
  /**
   * 获取回收站列表
   */
  async dustbinList() {
    const data = await this.ctx.service.package.dustbinList();
    this.ctx.sendSuccess(data);
  }
  /**
   * 从回收站还原
   */
  async dustbinRestore() {
    this.ctx.validate({
      id: {
        type: 'mongo-id',
      },
    }, this.ctx.params);
    const data = await this.ctx.service.package.dustbinRestore();
    this.ctx.sendSuccess(data);
  }
  /**
   * 从回收站删除数据（彻底删除数据）
   */
  async dustbinDelete() {
    this.ctx.validate({
      id: {
        type: 'mongo-id',
      },
    }, this.ctx.params);
    const data = await this.ctx.service.package.dustbinDelete();
    this.ctx.sendSuccess(data);
  }
}

module.exports = PackageController;
